package com.hardware;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
public class HardwareApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(HardwareApplication.class, args);

        // 项目运行成功输出
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path"); // 项目根路径 application.yml 里面配置的
        path = (path == null?"":path);
        System.out.println("\n----------------------------------------------------------\n\t" +
                "项目运行成功 URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                "Local: \t\thttp://127.0.0.1:" + port + path + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "/swagger-ui/index.html \n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html \n\t" +
                "接口数据地址: \thttp://" + ip + ":" + port + path + "/v3/api-docs \n" +
                "----------------------------------------------------------");
    }

}
